<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                template="./template.xhtml">

    <ui:define name="title">
        Kết quả xổ số
    </ui:define>

    <ui:define name="content">
        <table>
            <tr>
                <td style="vertical-align: top">
                    <h:form>
                        <p:panel header="Tìm kiếm">
                            <h:panelGrid columns="2">
                                Chọn tỉnh* 
                                <p:selectOneMenu value="#{lotteryBean.selectedProvince}" height="200" style="width: 150px">
                                    <f:selectItem itemLabel="Tất cả" itemValue="all"/>
                                    <f:selectItems value="#{lotteryBean.allAreas}"/>
                                </p:selectOneMenu>
                                Ngày bắt đầu*  <p:calendar value="#{lotteryBean.startDate}" id="startDate" navigator="true" pattern="dd/MM/yyyy" timeZone="Asia/Saigon"
                                                           required="true" requiredMessage="Bạn chưa chọn ngày bắt đầu"/>
                                Ngày kết thúc* <p:calendar value="#{lotteryBean.endDate}" id="endDate" navigator="true" pattern="dd/MM/yyyy" timeZone="Asia/Saigon"
                                                           required="true" requiredMessage="Bạn chưa chọn ngày kết thúc"/>
                                &nbsp; <p:commandButton value="Xem kết quả" action="#{lotteryBean.findLotteryResults()}" update="resultForm"/>
                                &nbsp; <p:commandButton value="Sửa lỗi KQXS" action="#{lotteryBean.fixKqxs()}" />
                            </h:panelGrid>
                        </p:panel>
                    </h:form>
                </td>

                <td>
                    <h:form id="resultForm">
                        <p:panel header="Kết quả tìm kiếm" rendered="#{lotteryBean.list.size() > 0}">
                            <h:panelGrid columns="1">
                                <ui:repeat value="#{lotteryBean.list}" var="kqxs">
                                    <div class="ui-datatable ui-widget">
                                        <div class="ui-paginator ui-paginator-top ui-widget-header ui-corner-tl ui-corner-tr" style="height: 30px">
                                            <center>
                                                <span class="ui-panel-title" style="vertical-align: middle;">KQXS #{kqxs.tinhQuay} ngày #{kqxs.ngayQuayStr}</span>
                                            </center>
                                        </div>
                                        <table>
                                            <tbody class="ui-datatable-data">
                                                <ui:repeat value="#{kqxs.giaiThuongList}" var="giaiThuong">
                                                    <tr class="ui-widget-content ui-datatable-even">
                                                        <td>#{giaiThuong.tenGiai}</td>
                                                        <td>
                                                            #{giaiThuong.boSo1}
                                                            &nbsp;
                                                            #{giaiThuong.boSo2}
                                                            &nbsp;
                                                            #{giaiThuong.boSo3}
                                                            &nbsp;
                                                            #{giaiThuong.boSo4}
                                                            &nbsp;
                                                            #{giaiThuong.boSo5}
                                                            &nbsp;
                                                            #{giaiThuong.boSo6}
                                                            &nbsp;
                                                            #{giaiThuong.boSo7}
                                                            &nbsp;
                                                            #{giaiThuong.boSo8}
                                                            &nbsp;
                                                        </td>
                                                    </tr>
                                                </ui:repeat>
                                                <tr>
                                                    <td colspan="2">
                                                        <p:commandButton value="Xóa" ajax="false" action="#{lotteryBean.delete(kqxs)}"/>
                                                    </td>
                                                </tr>
                                            </tbody> 
                                        </table>
                                    </div>
                                    <br/>
                                </ui:repeat>
                            </h:panelGrid>
                        </p:panel>
                    </h:form>
                </td>
            </tr>
        </table>

    </ui:define>

</ui:composition>
